<template>
  <a-upload
    v-model:file-list="fileList"
    name="uploadFile"
    :multiple="true"
    :action="baseURL+'/file/upload/'"
    @change="handleChange"
  >
    <a-button type="primary">
      <upload-outlined></upload-outlined>
      上传
    </a-button>
  </a-upload>
</template>
<script setup>
import {ref,reactive} from "vue"
import { message } from 'ant-design-vue';
const baseURL = import.meta.env.VITE_APP_API_URL;
const fileList = ref([])
const loading = ref(false);
const props = defineProps({
    value: [Number, String, Object],
  });
  const emit = defineEmits(['update:value']);
const handleChange = (info) => {
      if (info.file.status !== 'uploading') {
        loading.value = true;
    return;
      }
      if (info.file.status === 'done') {
        console.log(info)
        let res= info.file.response
        emit('update:value', res.data);
        // message.success(`${info.file.name} file uploaded successfully`);
      } else if (info.file.status === 'error') {
        // message.error(`${info.file.name} file upload failed.`);
        loading.value = false;
        message.error('upload error');
      }
    };
</script>
<style scoped>

</style>
